#include <stdio.h>
#include <stdlib.h>
#define MAX 20
#define INFINITY 999

typedef struct Adj_Matrix
{
	int M[MAX][MAX];
	int data[MAX];
	int node_num;
};

void creat_G(Adj_Matrix &G)
{
	int martix[MAX][MAX] = {{0, 1, 1, 1, 1},
							{1, 0, INFINITY, 1, INFINITY},
							{1, INFINITY, 0, 1, INFINITY},
							{1, 1, 1, 0, 1},
							{1, INFINITY, INFINITY, 1, 0}};
	int d[MAX] = {0, 1, 2, 3, 4};
	for (int i = 0; i < MAX; i++)
	{
		G.data[i] = d[i];
		for (int j = 0; j < MAX; j++)
		{
			G.M[i][j] = martix[i][j];
		}
	}
	G.node_num = 5;
}

void creat_w(Adj_Matrix &G)
{
	int data[8] = {0, 1, 2, 3, 4, 5, 6, 7};

	int weight_matrix[MAX][MAX] = {
		/*		 0, 1, 2, 3, 4, 5, 6, 7*/
		{0, 2, 2, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY}, //0
		{2, 0, INFINITY, INFINITY, 3, INFINITY, INFINITY, 1},		 //1
		{2, INFINITY, 0, 1, INFINITY, INFINITY, INFINITY, INFINITY}, //2
		{INFINITY, INFINITY, 1, 0, INFINITY, 1, INFINITY, INFINITY}, //3
		{INFINITY, 3, INFINITY, INFINITY, 0, 2, 2, 2},				 //4
		{INFINITY, INFINITY, INFINITY, 1, 2, 0, 2, INFINITY},		 //5
		{INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, 2, 0, 3}, //6
		{INFINITY, 1, INFINITY, INFINITY, INFINITY, INFINITY, 3, 0}  //7
	};
	for (int i = 0; i < MAX; i++)
	{
		G.data[i] = data[i];
		for (int j = 0; j < MAX; j++)
		{
			G.M[i][j] = weight_matrix[i][j];
		}
	}
	G.node_num = 8;
}

void creat_kosaraju(Adj_Matrix &G)
{
	int data[8] = {0, 1, 2, 3, 4, 5, 6};

	int weight_matrix[MAX][MAX] = {
		{INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY},
		//  0     1   2    3    4    5    6
		{INFINITY, INFINITY, 1, 1, INFINITY, INFINITY, INFINITY},			   //1
		{INFINITY, INFINITY, INFINITY, INFINITY, 1, INFINITY, INFINITY},	   //2
		{INFINITY, INFINITY, INFINITY, INFINITY, 1, 1, INFINITY},			   //3
		{INFINITY, 1, INFINITY, INFINITY, INFINITY, INFINITY, 1},			   //4
		{INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, 1},	   //5
		{INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY} //6
	};
	for (int i = 0; i < MAX; i++)
	{
		G.data[i] = data[i];
		for (int j = 0; j < MAX; j++)
		{
			G.M[i][j] = weight_matrix[i][j];
		}
	}
	G.node_num = 7;
}

// Topological sort
void creat_Topological(Adj_Matrix &G)
{
	int data[8] = {0, 1, 2, 3, 4, 5, 6};

	int weight_matrix[MAX][MAX] = {
		{0, 1, 1, 1, INFINITY, INFINITY, INFINITY},
		{INFINITY, 0, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY},
		{INFINITY, 1, 0, INFINITY, 1, INFINITY, INFINITY},
		{INFINITY, INFINITY, INFINITY, 0, 1, INFINITY, INFINITY},
		{INFINITY, INFINITY, INFINITY, INFINITY, 0, INFINITY, INFINITY},
		{INFINITY, INFINITY, INFINITY, 1, 1, 0, INFINITY},
		{INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY},
	};
	for (int i = 0; i < MAX; i++)
	{
		G.data[i] = data[i];
		for (int j = 0; j < MAX; j++)
		{
			G.M[i][j] = weight_matrix[i][j];
		}
	}
	G.node_num = 7;
}

void creat_critical(Adj_Matrix &G)
{
	int data[MAX] = {0, 1, 2, 3, 4, 5, 6};

	int weight_matrix[MAX][MAX] = {
		{0, 4, 8, INFINITY, INFINITY, INFINITY, INFINITY},
		{INFINITY, 0, 4, INFINITY, INFINITY, INFINITY, 1},
		{INFINITY, INFINITY, 0, 1, 3, INFINITY, INFINITY},
		{INFINITY, INFINITY, INFINITY, 0, INFINITY, 2, INFINITY},
		{INFINITY, INFINITY, INFINITY, INFINITY, 0, 4, INFINITY},
		{INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, 0, INFINITY},
		{INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, 4, 0},
	};
	for (int i = 0; i < MAX; i++)
	{
		G.data[i] = data[i];
		for (int j = 0; j < MAX; j++)
		{
			G.M[i][j] = weight_matrix[i][j];
		}
	}
	G.node_num = 7;
}